import { post } from "./apiRoute";
import axios from 'axios';

export const getPaymentToken = () => {
  return axios({
    method: 'post',
    url: 'https://api-m.sandbox.paypal.com/v1/oauth2/token',
    data: data,
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  });
}

export const signUpApi = (postJson) => {
  return post("/UserAccount/CreateUserAccount", postJson).then((res) => {
    return res;
  })
}

// Email
export const getEmailVerifyApi = (postJson) => {
  return post("/UserAccount/GetEmailVerify", postJson).then((res) => {
    return res;
  })
}

export const loginApi = (postJson) => {
  return post("/UserAccount/Login", postJson).then((res) => {
    return res;
  })
}

export const getUserIsAdmin = (postJson) => {
  return post("/UserAccount/GetUserIsAdmin", postJson).then((res) => {
    return res;
  })
}

// {
//   "filterType": "string",
//   "year": "string",
//   "brand": "string",
//   "model": "string",
//   "engine": "string",
//   "fuelType": "string"
// }
export const getProductsFilterApi = (postJson) => {
  return post("/Product/GetProductsFilter", postJson).then((res) => {
    return res;
  })
}

// {
//   "filterType": "string",
//   "year": "string",
//   "brand": "string",
//   "model": "string",
//   "engine": "string",
//   "fuelType": "string"
//   "pageNum" : "int"
//   "pageSize" : "int"
// }
export const getProductsApi = (postJson) => {
  return post("/Product/GetProducts", postJson).then((res) => {
    return res;
  })
}

export const getAllProducts = (postJson) => {
  return post("/Product/GetAllProducts", postJson).then((res) => {
    return res;
  })
}

// {
//   "filterType": "string",
//   "year": "string",
//   "brand": "string",
//   "model": "string",
//   "engine": "string",
//   "fuelType": "string"
// }
export const getProductsFilter = (postJson) => {
  return post("/Product/GetProductsFilter", postJson).then((res) => {
    return res;
  })
}

// {
//   "year": "string",
//   "brand": "string",
//   "model": "string",
//   "engine": "string",
//   "fuelType": "string"
// }
export const getProducts = (postJson) => {
  return post("/Product/GetProducts", postJson).then((res) => {
    return res;
  })
}

export const getEmailReVerify = (postJson) => {
  return post("/UserAccount/GetEmailReVerify", postJson).then((res) => {
    return res;
  })
}

export const changePassword = (postJson) => {
  return post("/UserAccount/ChangePassword", postJson).then((res) => {
    return res;
  })
}

export const changeProfile = (postJson) => {
  return post("/UserAccount/ChangeProfile", postJson).then((res) => {
    return res;
  })
}

export const getProductInfo = (postJson) => {
  return post("/Product/GetProductInfo", postJson).then((res) => {
    return res;
  })
}

export const getCartInfo = (postJson) => {
  return post("/Cart/GetCartInfo", postJson).then((res) => {
    return res;
  })
}

export const changeProductCount = (postJson) => {
  return post("/Cart/ChangeProductCount", postJson).then((res) => {
    return res;
  })
}

export const removeCartProduct = (postJson) => {
  return post("/Cart/RemoveCartProduct", postJson).then((res) => {
    return res;
  })
}

export const addProductToCart = (postJson) => {
  return post("/Cart/AddProductToCart", postJson).then((res) => {
    return res;
  })
}

export const getOrderList = (postJson) => {
  return post("/Order/GetOrderList", postJson).then((res) => {
    return res;
  })
}

export const getUserListAdmin = (postJson) => {
  return post("/Admin/GetUserListAdmin", postJson).then((res) => {
    return res;
  })
}

export const createUserAdmin = (postJson) => {
  return post("/Admin/CreateUserAdmin", postJson).then((res) => {
    return res;
  })
}

export const editUserAdmin = (postJson) => {
  return post("/Admin/EditUserAdmin", postJson).then((res) => {
    return res;
  })
}

export const getProductListAdmin = (postJson) => {
  return post("/Admin/GetProductListAdmin", postJson).then((res) => {
    return res;
  })
}

export const createProductAdmin = (postJson) => {
  return post("/Admin/CreateProductAdmin", postJson).then((res) => {
    return res;
  })
}

export const editProductAdmin = (postJson) => {
  return post("/Admin/EditProductAdmin", postJson).then((res) => {
    return res;
  })
}

export const getOrderListAdmin = (postJson) => {
  return post("/Admin/GetOrderListAdmin", postJson).then((res) => {
    return res;
  })
}

export const getUserBinListAdmin = (postJson) => {
  return post("/Admin/GetUserBinListAdmin", postJson).then((res) => {
    return res;
  })
}

export const getProductBinListAdmin = (postJson) => {
  return post("/Admin/GetProductBinListAdmin", postJson).then((res) => {
    return res;
  })
}

export const getOrderBinListAdmin = (postJson) => {
  return post("/Admin/GetOrderBinListAdmin", postJson).then((res) => {
    return res;
  })
}

export const createOrder = (postJson) => {
  return post("/Order/CreateOrder", postJson).then((res) => {
    return res;
  })
}

export const createSingleOrder = (postJson) => {
  return post("/Order/CreateSingleOrder", postJson).then((res) => {
    return res;
  })
}

export const editOrderReturn = (postJson) => {
  return post("/Order/EditOrderReturn", postJson).then((res) => {
    return res;
  })
}

export const receiveOrder = (postJson) => {
  return post("/Order/ReceiveOrder", postJson).then((res) => {
    return res;
  })
}

export const approveOrder = (postJson) => {
  return post("/Order/ApproveOrder", postJson).then((res) => {
    return res;
  })
}

export const saveOrderReturnExpressInfo = (postJson) => {
  return post("/Order/SaveOrderReturnExpressInfo", postJson).then((res) => {
    return res;
  })
}

export const getOrderDeliverExpressInfo = (postJson) => {
  return post("/Order/GetOrderDeliverExpressInfo", postJson).then((res) => {
    return res;
  })
}


export const getOrderExpressInfo = (postJson) => {
  return post("/Order/GetOrderExpressInfo", postJson).then((res) => {
    return res;
  })
}


export const editOrderTrackingAdmin = (postJson) => {
  return post("/Admin/EditOrderTrackingAdmin", postJson).then((res) => {
    return res;
  })
}

export const confirmReturnAdmin = (postJson) => {
  return post("/Admin/ConfirmReturnAdmin", postJson).then((res) => {
    return res;
  })
}

export const revokeReturnAdmin = (postJson) => {
  return post("/Admin/RevokeReturnAdmin", postJson).then((res) => {
    return res;
  })
}

export const uploadImageAdmin = (postJson) => {
  return post("/Admin/UploadImageAdmin", postJson).then((res) => {
    return res;
  })
}

export const saveProductDetailAdmin = (postJson) => {
  return post("/Admin/SaveProductDetailAdmin", postJson).then((res) => {
    return res;
  })
}

export const deleteOrderAdmin = (postJson) => {
  return post("/Admin/DeleteOrderAdmin", postJson).then((res) => {
    return res;
  })
}

export const deleteProductAdmin = (postJson) => {
  return post("/Admin/DeleteProductAdmin", postJson).then((res) => {
    return res;
  })
}

export const deleteUserAdmin = (postJson) => {
  return post("/Admin/DeleteUserAdmin", postJson).then((res) => {
    return res;
  })
}

export const recoverOrderAdmin = (postJson) => {
  return post("/Admin/RecoverOrderAdmin", postJson).then((res) => {
    return res;
  })
}


export const recoverUserAdmin = (postJson) => {
  return post("/Admin/RecoverUserAdmin", postJson).then((res) => {
    return res;
  })
}


export const recoverProductAdmin = (postJson) => {
  return post("/Admin/RecoverProductAdmin", postJson).then((res) => {
    return res;
  })
}

export const saveOrderDeliverExpressInfoAdmin = (postJson) => {
  return post("/Admin/SaveOrderDeliverExpressInfoAdmin", postJson).then((res) => {
    return res;
  })
} 

export const getOrderExpressInfoAdmin = (postJson) => {
  return post("/Admin/GetOrderExpressInfoAdmin", postJson).then((res) => {
    return res;
  })
} 